import requests
import re
import xml.etree.ElementTree as ET

url = 'http://192.168.0.7:8080//services/GZJDDeviceService'

headers = {
    'Content-Type':'text/xml'
}

barCode = 'SPDPYYY01ZA501845180108'
body = f'''
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                 xmlns:ser="http://service.jgmes.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:GetBluetoothAddressBySN>
         <barCode>{barCode}</barCode>  
      </ser:GetBluetoothAddressBySN>
   </soapenv:Body>
</soapenv:Envelope>
'''

res = requests.post(url,headers=headers,data=body)
print(res.status_code)
print(res.text)

match_res_str = re.findall('<data xmlns="http://service.jgmes.com">(.*?)</data>', res.text)
print(match_res_str[0])

# tree = ET.parse(res.text)
# root = tree.getroot()
root = ET.fromstring(res.text)
print(root.tag)

z = root.find('soap:Body')
print(z.tag)
